<?php
class ServiceController extends default_controllers_Controller
{
	protected function _initSubMenu()
	{
		$subMenu = core_Services   ::getInstance()->getCollection();

		foreach($subMenu->items() as $item) {
			$item->url      = $this->view->url(array('alias' => $item->alias, 'controller' => $this->_request->getControllerName()), 'controller-alias');
			$item->isActive = $this->_request->getParam('alias') == $item->alias;
		}

		$subMenu->first()->url      = $this->view->url(array('controller' => $this->_request->getControllerName()), 'controller');
		$subMenu->first()->isActive = !$this->_request->getParam('alias');

		$this->view->subMenu = $subMenu;
	}

	public function indexAction()
	{
		if (!$entry = $this->getEntryByIdOrAlias(core_Services::getInstance())) {
			$this->_redirect('/' . $this->_request->getControllerName());
		}

		$this->view->entry      = $entry;
	}
}